package com.peach.config;

import com.peach.interceptor.Interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器到SpringMVC机制中，然后它会返回一个拦截器注册
        InterceptorRegistration ir = registry.addInterceptor(new Interceptor());
        // 指定拦截匹配模式
        //ir.addPathPatterns("/");
       ir.addPathPatterns("/user/*").addPathPatterns("/news/*").addPathPatterns("/activity/*").addPathPatterns("/index/*").addPathPatterns("/index");
     //   ir.addPathPatterns("/*").excludePathPatterns("/login2").excludePathPatterns("/login");
    }

}
